﻿<UserControl x:Class="OPMLtools.Infrastructure.Views.LogView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:b="clr-namespace:OPMLtools.Common.Behaviors"
             xmlns:conv="clr-namespace:OPMLtools.Common.Converters"
             xmlns:vm="clr-namespace:OPMLtools.Infrastructure.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <vm:LogViewModel x:Key="vmLogViewModel"/>
        <conv:ImageConverter x:Key="conImageConverter"/>
    </UserControl.Resources>
    <Grid>
        <GroupBox Header="Logs" DataContext="{Binding Source={StaticResource vmLogViewModel}}" Margin="5,1,5,5">
            <ListView Margin="3" ItemsSource="{Binding Logs}" b:ListBoxExtenders.AutoScrollToEnd="True">
                <ListView.View>
                    <GridView>

                        <GridViewColumn >
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Image Height="16" Width="16" Source="{Binding Type,Converter={StaticResource conImageConverter }}" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                        <GridViewColumn Header="Time" Width="Auto">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate >
                                    <TextBlock Text="{Binding Time}" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                        <GridViewColumn Header="Message" Width="300">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate >
                                    <TextBlock Text="{Binding Message}" HorizontalAlignment="Center" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                    </GridView>
                </ListView.View>
            </ListView>
        </GroupBox>
    </Grid>
</UserControl>
